package com.neegix.log.exceptionLog.infrastructure.repository.impl;

import com.neegix.application.query.NebulaSQL;
import com.neegix.base.PageVO;
import com.neegix.log.exceptionLog.application.repository.ExceptionLogQueryRepository;
import com.neegix.log.exceptionLog.application.service.query.mapper.ExceptionLogQueryMapper;
import com.neegix.log.exceptionLog.infrastructure.repository.dataobject.ExceptionLogDO;
import com.neegix.log.exceptionLog.infrastructure.repository.mapper.ExceptionLogMapper;
import com.neegix.log.exceptionLog.infrastructure.repository.mapper.customized.ExceptionLogCustomizedMapper;
import com.neegix.log.exceptionLog.interfaces.vo.ExceptionLogVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

 /**
  * This file is auto-generated by nebula-framework-generator.
  * The auto-generation plugin was developed using IntelliJ IDEA Community Edition.
  * Thanks to JetBrains for their outstanding contributions to the developer community.
  * <p>
  * The code generated by this tool is owned by the user of the tool.
  * The tool itself is copyrighted by <a href="https://www.neegix.com">https://www.neegix.com</a>.
  *
  * @author <a href="https://www.neegix.com">https://www.neegix.com</a>
  * @version 1.0.0
  * @since 2024-12-19 15:04:54
  */

@Repository
public class ExceptionLogQueryRepositoryImpl implements ExceptionLogQueryRepository {

    @Autowired
    private ExceptionLogMapper exceptionLogMapper;

    @Autowired
    private ExceptionLogCustomizedMapper exceptionLogCustomizedMapper;

//    @Override
//    public Optional<ExceptionLogVO> findById(Long id) {
//        ExceptionLogDO exceptionLogDO = exceptionLogMapper.selectByPrimaryKey(id);
//        return Optional.ofNullable(ExceptionLogAssembler.INSTANCE.covertVO(ExceptionLogConverter.INSTANCE.covertDTO(exceptionLogDO)));
//    }

//    @Override
//    public Integer selectCount(List<Long> ids) {
//        return exceptionLogCustomizedMapper.selectCountByIds(ids);
//    }

    @Override
    public PageVO<ExceptionLogVO> findPage(Integer currentPage, Integer pageSize, NebulaSQL nebulaSQL) {
        nebulaSQL.setPager(currentPage, pageSize);
        List<ExceptionLogDO> result = exceptionLogMapper.selectList(nebulaSQL);
        Long total = exceptionLogMapper.selectCount(nebulaSQL);
        PageVO<ExceptionLogVO> page = new PageVO<>(currentPage, pageSize);
        page.setTotal(total);
        page.setResult(ExceptionLogQueryMapper.INSTANCE.covertVO(result));
        return page;
    }
}
